home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-21 | 3.8 KB | 121 lines | [TEXT/MPS ] |
- #
- # File: LinkSharedLibrary
- #
- # Contains: Script to link a shared library
- #
- # Copyright: © 1992-1993 by Apple Computer, Inc., all rights reserved.
- #
- #
-
- Set OutFile ""
- Set InObj ""
- Set SymFile ""
- Set Error 0
- Set NoMerge 0
- Set model "-model far"
- If "{TempFolder}" != ""
- Set Scratch "{TempFolder}"
- Else
- Set Scratch "{CPlusScratch}"
- End
- Set MapFile "{Scratch}SharedLibTemp.Map"
- Set UsrMap 0
- LOOP
- If "{1}" == "" || "{1}" !~ /-≈/
- Break;
- Else If "{1}" =~ /-link/
- Shift; Break;
- Else If "{1}" =~ /-near/
- Set model "-model near"
- Else If "{1}" =~ /-far/
- Set model "-model far"
- Else If "{1}" =~ /-noMerge/
- Set NoMerge 1
- Else If "{1}" =~ /-map/
- Set MapFile "{2}"; Shift 2; Set UsrMap 1; Continue
- Else If "{1}" =~ /-symfile/
- Set SymFile "{2}"; Shift 2; Continue
- Else If "{1}" =~ /-obj/
- Set InObj "{2}"; Shift 2; Continue
- Else If "{1}" =~ /-lib/
- Set OutFile "{2}"; Shift 2; Continue
- Else
- Set Error 1
- Break;
- End
- Shift
- End
- If "{InObj}" == "" || "{OutFile}" == ""
- Set Error 1
- End
- If {Error}
- Echo "Usage: LinkSharedLibrary -lib <OutputLibrary>"
- Echo " -obj <ObjectRootName>"
- Echo " -map <MapFileName>"
- Echo " -noMerge"
- Echo " -link <Parameters for the link>"
- Echo ""
- Echo "Must be used after using BuildSharedLibrary"
- Echo ""
- Echo " The name after the -obj flag describes the base name for all of"
- Echo " the files resulting from invoking this tool. The following"
- Echo " are added to the base name you supply:"
- Echo " .lib.o - The actual shared library object file"
- Echo " .libr.r - Resource to rez with the shared library resource"
- Echo " .deps - File used to create the dependency ('libi') resource"
- Echo " .init.o - Initialization code for the library\n"
- Echo " .ia.o - Initialization code for the library\n"
- Echo " This should be the same name you passed to the BuildSharedLibrary"
- Echo " Script"
- Echo ""
- Echo " Everything after -link will be passed to the linker directly."
- Echo " The list of libraries to link with must be last"
- Echo " or after the -link switch."
- Echo " The link automatically merges segments Main, STDCLIB, STDIO,"
- Echo " CSANELib, SANELIB, %Complex, SADEV, and INTENV unless you"
- Echo " specify the NoMerge flag"
- Exit 10
- End
- If {Progress}
- Echo "∂t∂tCreating shared Library file ∂"{OutFile}∂""
- End
-
- If {NoMerge} == 0
- Set SegMerge "-sn STDIO=Main -sn STDCLIB=Main -sn CSANELib=Main -sn %Complex=Main -sn SADEV=Main -sn INTENV=Main -sn SANELIB=Main"
- Else
- Set SegMerge ""
- End
- Duplicate -y "{InObj}.libr.r" "{Scratch}SharedLibTemp.temp.r"
-
- Delete -i "{Scratch}SharedLibTemp.RSRC.SYM"
- If "`Exists -f "{InObj}.deps"`"
- Set HaveDeps 1
- Link {model} -d -t rsrc -c RSED ∂
- -sg %A5Init=A5Init -ra %A5Init=resLocked -m DynamicCodeEntry -o "{Scratch}SharedLibTemp.RSRC" ∂
- "{InObj}.init.o" "{InObj}.ia.o" "{InObj}.lib.o" -map >"{MapFile}" ∂
- {SegMerge} {"Parameters"}
- CreateLibraryLoadRsrc -map "{MapFile}" -out "{Scratch}SharedLibTemp.temp.r" ∂
- -resid SLMID -a -readx "{InObj}.deps"
- Else
- Set HaveDeps 0
- Link {model} -d -t rsrc -c RSED ∂
- -sg %A5Init=A5Init -ra %A5Init=resLocked -m DynamicCodeEntry -o "{Scratch}SharedLibTemp.RSRC" ∂
- "{InObj}.init.o" "{InObj}.ia.o" "{InObj}.lib.o" ∂
- {SegMerge} {"Parameters"}
- End
- If "`Exists -f "{Scratch}SharedLibTemp.RSRC.SYM"`"
- Duplicate -y "{Scratch}SharedLibTemp.RSRC.SYM" "{SymFile}"
- Delete -i "{Scratch}SharedLibTemp.RSRC.SYM"
- End
-
- Echo "Include ∂"{Scratch}SharedLibTemp.RSRC∂" 'CODE' as SLMType;" >> "{Scratch}SharedLibTemp.temp.r"
- Echo "Delete SLMType (∂"32-bit bootstrap∂");" >> "{Scratch}SharedLibTemp.temp.r"
-
- Delete -i "{OutFile}" ∑∑ Dev:Null
- Rez -a -t libr -c OMGR ∂
- -o "{OutFile}" "{Scratch}SharedLibTemp.temp.r"
- SetFile -a ib "{OutFile}"
- delete -i "{Scratch}SharedLibTemp.temp.r" "{Scratch}SharedLibTemp.RSRC"
- If {HaveDeps} != 0 AND {UsrMap} == 0
- Delete -i "{MapFile}"
- End